# $Id: PKGBUILD 166932 2012-09-22 13:11:31Z thomas $
# Maintainer: dorphell <dorphell@archlinux.org>
# Contributor: Jose Javier  <jojapa@terra.es>
pkgname=tftp-hpa
pkgver=5.2
pkgrel=3
pkgdesc="Official tftp server"
arch=('i686' 'x86_64')
url="http://www.kernel.org/pub/software/network/tftp/tftp-hpa/"
license=('BSD')
depends=('readline>=6.0.00')
conflicts=('netkit-tftp')
backup=('etc/conf.d/tftpd')
source=(http://www.kernel.org/pub/software/network/tftp/tftp-hpa/$pkgname-$pkgver.tar.gz 
       tftpd.rc 
       tftpd.conf 
       LICENSE
       tftpd.service
       tftpd.socket
       tftp-hpa-0.49-fortify-strcpy-crash.patch)
md5sums=('3de3038e7c2bf6fc5d496825893ac8e7'
         '83fbb6f52205d95951a3c059e5351ca2'
         'f41f484f94e91175e9183e872a2bff3b'
         '6ce21e27b6fdc1a1adf85c81e42aeecf'
         '165b98f814f74568635a720e674d7f18'
         'a23369ea33be8b4a5427ec2cfc5373dd'
         '22e8629ef19bc276a102c5d4d284c1bd')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  # fix #28103
  patch -Np1 -i ../tftp-hpa-0.49-fortify-strcpy-crash.patch
  ./configure --prefix=/usr --mandir=/usr/share/man --without-tcpwrappers 
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}" 
  make INSTALLROOT="${pkgdir}" install
  install -d "${pkgdir}/etc/rc.d"
  install -d "${pkgdir}/srv/tftp"
  install -m755 "${srcdir}/tftpd.rc" "${pkgdir}/etc/rc.d/tftpd"
  install -D -m644 "${srcdir}/tftpd.conf" "${pkgdir}/etc/conf.d/tftpd"
  install -D -m655 "${srcdir}/tftpd.service" "${pkgdir}/usr/lib/systemd/system/tftpd.service"
  install -D -m655 "${srcdir}/tftpd.socket" "${pkgdir}/usr/lib/systemd/system/tftpd.socket"
  install -D -m644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  # Remove conflict with iputils
  rm "${pkgdir}/usr/share/man/man8/tftpd.8"  
}
